package com.apartment.own.mapper;

import java.util.List;
import java.util.Map;

import com.apartment.own.domain.OwnOrdWaterBills;
import com.apartment.own.request.bills.HouseWaterBillsQuery;
import com.apartment.own.response.bill.BillsResp;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 流水记录Mapper接口
 *
 * @author @Dog_E
 * @date 2020-08-28
 */
public interface OwnOrdWaterBillsMapper extends BaseMapper<OwnOrdWaterBills> {
    /**
     * 查询流水记录
     *
     * @param id 流水记录ID
     * @return 流水记录
     */
    public OwnOrdWaterBills selectOwnOrdWaterBillsById(Long id);

    /**
     * 查询流水记录列表
     *
     * @param wrappery 构建查询条件
     * @return 流水记录集合
     */
//@Select("select * from own_ord_water_bills bill inner join own_account_installment ac on bill.account_id=ac.id ${ew.customSqlSegment}")
    @Select("select * from own_ord_water_bills bill inner join own_res_house_room_conf room on bill.house_resource_id=room.id left join own_res_house_resource house on room.key_resource_id=house.id inner join sys_user user on bill.handle_sys_user_id=user.user_id inner join own_account_installment acin on bill.account_installment_id=acin.id  ${ew.customSqlSegment}")
    public List<Map> selectOwnOrdWaterBillsList(@Param(Constants.WRAPPER) Wrapper wrappery);

    /**
     * 新增流水记录
     *
     * @param ownOrdWaterBills 流水记录
     * @return 结果
     */
    public int insertOwnOrdWaterBills(OwnOrdWaterBills ownOrdWaterBills);

    /**
     * 修改流水记录
     *
     * @param ownOrdWaterBills 流水记录
     * @return 结果
     */
    public int updateOwnOrdWaterBills(OwnOrdWaterBills ownOrdWaterBills);

    /**
     * 删除流水记录
     *
     * @param id 流水记录ID
     * @return 结果
     */
    public int deleteOwnOrdWaterBillsById(Long id);

    /**
     * 批量删除流水记录
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    public int deleteOwnOrdWaterBillsByIds(Long[] ids);

    /**
     * 根据id查询流水详细信息
     *
     * @param
     * @return
     */
    @Select("select * from own_ord_water_bills bill inner join own_res_house_room_conf room on bill.house_resource_id=room.id inner join own_res_house_resource house on room.key_resource_id=house.id inner join sys_user user on bill.handle_sys_user_id=user.user_id  ${ew.customSqlSegment}")
    public BillsResp selectOwnOrdWaterBillById(@Param(Constants.WRAPPER) Wrapper wrappery);
}
